<!DOCTYPE html>

<html>
<head>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">

<title>class Pwqgen::Generator - RDoc Documentation</title>

<link type="text/css" media="screen" href="../rdoc.css" rel="stylesheet">

<script type="text/javascript">
  var rdoc_rel_prefix = "../";
</script>

<script type="text/javascript" charset="utf-8" src="../js/jquery.js"></script>
<script type="text/javascript" charset="utf-8" src="../js/navigation.js"></script>
<script type="text/javascript" charset="utf-8" src="../js/search_index.js"></script>
<script type="text/javascript" charset="utf-8" src="../js/search.js"></script>
<script type="text/javascript" charset="utf-8" src="../js/searcher.js"></script>
<script type="text/javascript" charset="utf-8" src="../js/darkfish.js"></script>


<body id="top" class="class">
<nav id="metadata">
  <nav id="home-section" class="section">
  <h3 class="section-header">
    <a href="../index.html">Home</a>
    <a href="../table_of_contents.html#classes">Classes</a>
    <a href="../table_of_contents.html#methods">Methods</a>
  </h3>
</nav>


  <nav id="search-section" class="section project-section" class="initially-hidden">
  <form action="#" method="get" accept-charset="utf-8">
    <h3 class="section-header">
      <input type="text" name="search" placeholder="Search" id="search-field"
             title="Type to search, Up and Down to navigate, Enter to load">
    </h3>
  </form>

  <ul id="search-results" class="initially-hidden"></ul>
</nav>


  <div id="file-metadata">
    <nav id="file-list-section" class="section">
  <h3 class="section-header">Defined In</h3>
  <ul>
    <li>lib/pwqgen/pwqgen.rb
    <li>lib/pwqgen/wordlist.rb
  </ul>
</nav>

    
  </div>

  <div id="class-metadata">
    
    <nav id="parent-class-section" class="section">
  <h3 class="section-header">Parent</h3>
  
  <p class="link">Object
  
</nav>

    
    <!-- Method Quickref -->
<nav id="method-list-section" class="section">
  <h3 class="section-header">Methods</h3>

  <ul class="link-list">
    
    <li><a href="#method-c-new">::new</a>
    
    <li><a href="#method-i-generate">#generate</a>
    
  </ul>
</nav>

  </div>

  <div id="project-metadata">
    <nav id="fileindex-section" class="section project-section">
  <h3 class="section-header">Pages</h3>

  <ul>
  
    <li class="file"><a href="../ChangeLog.html">ChangeLog</a>
  
    <li class="file"><a href="../Gemfile.html">Gemfile</a>
  
    <li class="file"><a href="../Rakefile.html">Rakefile</a>
  
  </ul>
</nav>

    <nav id="classindex-section" class="section project-section">
  <h3 class="section-header">Class and Module Index</h3>

  <ul class="link-list">
  
    <li><a href="../Pwqgen.html">Pwqgen</a>
  
    <li><a href="../Pwqgen/Generator.html">Pwqgen::Generator</a>
  
  </ul>
</nav>

  </div>
</nav>

<div id="documentation">
  <h1 class="class">class Pwqgen::Generator</h1>

  <div id="description" class="description">
    
  </div><!-- description -->

  
  
  
  <section id="5Buntitled-5D" class="documentation-section">
    

    

    

    

    <!-- Methods -->
    
     <section id="public-class-5Buntitled-5D-method-details" class="method-section section">
      <h3 class="section-header">Public Class Methods</h3>

    
      <div id="method-c-new" class="method-detail ">
        
        <div class="method-heading">
          <span class="method-name">new</span><span
            class="method-args">()</span>
          <span class="method-click-advice">click to toggle source</span>
        </div>
        

        <div class="method-description">
          
          
          

          
          <div class="method-source-code" id="new-source">
            <pre><span class="ruby-comment"># File lib/pwqgen/pwqgen.rb, line 44</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">initialize</span>
        <span class="ruby-identifier">@@wordlist_size</span> = <span class="ruby-identifier">@@wordlist</span>.<span class="ruby-identifier">length</span>
        <span class="ruby-identifier">@@separators</span> = <span class="ruby-string">&quot;-_!$&amp;*+=23456789&quot;</span>.<span class="ruby-identifier">split</span>(<span class="ruby-regexp">%r/</span>)
        <span class="ruby-identifier">@@separators_size</span> = <span class="ruby-identifier">@@separators</span>.<span class="ruby-identifier">length</span>
        <span class="ruby-ivar">@rand</span> = <span class="ruby-constant">Random</span>.<span class="ruby-identifier">new</span>
<span class="ruby-keyword">end</span></pre>
          </div><!-- new-source -->
          
        </div>

        

        
      </div><!-- new-method -->

    
    </section><!-- public-class-method-details -->
  
     <section id="public-instance-5Buntitled-5D-method-details" class="method-section section">
      <h3 class="section-header">Public Instance Methods</h3>

    
      <div id="method-i-generate" class="method-detail ">
        
        <div class="method-heading">
          <span class="method-name">generate</span><span
            class="method-args">(length = 3)</span>
          <span class="method-click-advice">click to toggle source</span>
        </div>
        

        <div class="method-description">
          
          <p>Public: Returns a random generated password string.</p>

<p>length - number of words used to create the passphrase.</p>

<p>Example</p>

<pre class="ruby"><span class="ruby-identifier">generate</span> <span class="ruby-value">2</span>
<span class="ruby-comment"># =&gt; &quot;Loyal8atomic&quot;</span>

<span class="ruby-identifier">generate</span>
<span class="ruby-comment"># =&gt; &quot;Gate*Abound&amp;hull&quot;</span>
</pre>

<p>Returns a password string.</p>
          

          
          <div class="method-source-code" id="generate-source">
            <pre><span class="ruby-comment"># File lib/pwqgen/pwqgen.rb, line 64</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">generate</span>(<span class="ruby-identifier">length</span> = <span class="ruby-value">3</span>)
        <span class="ruby-identifier">output</span> = <span class="ruby-constant">Array</span>.<span class="ruby-identifier">new</span>
        <span class="ruby-keyword">for</span> <span class="ruby-identifier">i</span> <span class="ruby-keyword">in</span> <span class="ruby-value">1</span><span class="ruby-operator">..</span><span class="ruby-identifier">length</span>
                <span class="ruby-identifier">output</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">@@wordlist</span>[<span class="ruby-ivar">@rand</span>.<span class="ruby-identifier">rand</span>(<span class="ruby-identifier">@@wordlist_size</span>)]
                <span class="ruby-identifier">output</span>[<span class="ruby-identifier">i</span><span class="ruby-operator">-</span><span class="ruby-value">1</span>] = <span class="ruby-identifier">output</span>[<span class="ruby-identifier">i</span><span class="ruby-operator">-</span><span class="ruby-value">1</span>].<span class="ruby-identifier">capitalize</span> <span class="ruby-keyword">if</span> <span class="ruby-ivar">@rand</span>.<span class="ruby-identifier">rand</span>(<span class="ruby-value">2</span>)

                <span class="ruby-identifier">output</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">@@separators</span>[<span class="ruby-ivar">@rand</span>.<span class="ruby-identifier">rand</span>(<span class="ruby-identifier">@@separators_size</span>)] <span class="ruby-keyword">unless</span> <span class="ruby-identifier">i</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">length</span>
        <span class="ruby-keyword">end</span>
        <span class="ruby-identifier">output</span>.<span class="ruby-identifier">join</span>
<span class="ruby-keyword">end</span></pre>
          </div><!-- generate-source -->
          
        </div>

        

        
      </div><!-- generate-method -->

    
    </section><!-- public-instance-method-details -->
  
  </section><!-- 5Buntitled-5D -->

</div><!-- documentation -->


<footer id="validator-badges">
  <p><a href="http://validator.w3.org/check/referer">[Validate]</a>
  <p>Generated by <a href="https://github.com/rdoc/rdoc">RDoc</a> 3.12.
  <p>Generated with the <a href="http://deveiate.org/projects/Darkfish-Rdoc/">Darkfish Rdoc Generator</a> 3.
</footer>

